/**
 * 
 */
package com.shine.icis.dao.imp;

import org.hibernate.Query;

import com.shine.icis.dao.ISubmitReportDAO;
import com.shine.icis.dao.imp.BaseHibernateDAO;
import com.shine.icis.hbean.SubmitReport;

/**
 * @author zsy
 *
 */
public class SubmitReportDAO extends BaseHibernateDAO implements ISubmitReportDAO {
	
	@Override
	public SubmitReport findById(String id) {
		SubmitReport sl = (SubmitReport)getSession().get(SubmitReport.class, id);
		return sl;
	}

	@Override
	public SubmitReport findByInsId(String insId) {
		Query query = getSession().createQuery("from SubmitReport as sr where sr.insId=:insId");
		query.setString("insId", insId);
		query.setMaxResults(1);
		return (SubmitReport)query.uniqueResult();
	}

	@Override
	public SubmitReport findBySubmitLogId(String submitLogId) {
		Query query = getSession().createQuery("from SubmitReport as sr where sr.submitLogId=:submitLogId");
		query.setString("submitLogId", submitLogId);
		query.setMaxResults(1);
		return (SubmitReport)query.uniqueResult();
	}

	@Override
	public boolean testPassed(String submitLogId) {
		Query query = getSession().createQuery("select sr.passed from SubmitReport as sr where sr.submitLogId=:submitLogId");
		query.setString("submitLogId", submitLogId);
		query.setMaxResults(1);
		return (Boolean)query.uniqueResult();
	}
}